<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>ESMS</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="/ssm_esms/static/css/font.css">
  <link rel="stylesheet" href="/ssm_esms/static/css/xadmin.css">
  <script type="text/javascript" src="/ssm_esms/static/js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="/ssm_esms/static/lib/layui/layui.js"></script>
  <script type="text/javascript" src="/ssm_esms/static/js/xadmin.js"></script>
  <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  <!--[if lt IE 9]>
  <!--<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>-->
  <!--<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>-->
  <!--<![endif]&ndash;&gt;-->

</head>

<body class="layui-anim layui-anim-up">

<div class="x-nav">
      <span class="layui-breadcrumb">
        <a >首页</a>
        <a >工资项管理</a>
        <a>
          <cite>工资项</cite></a>
      </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="x-body layui-anim layui-anim-up">
  <form class="layui-form" action="">
    <div class="x-body" id="container">
      <div class="demoTable">
        迟到罚金：
        <div class="layui-inline">
          <input class="layui-input" name="late_buckle_payTxt" id="late_buckle_payTxt" lay-verify="late_buckle_payTxtVerify" autocomplete="off">
        </div>
        元/次
      </div>
      <br>
      <div class="demoTable">
        早退罚金：
        <div class="layui-inline">
          <input class="layui-input" name="early_buckle_payTxt" id="early_buckle_payTxt" lay-verify="early_buckle_payTxtVerify" autocomplete="off">
        </div>
        元/次
      </div>
      <br>
      <div class="demoTable">
        出差补贴：
        <div class="layui-inline">
          <input class="layui-input" name="missionallowanceTxt" id="missionallowanceTxt" lay-verify="missionallowanceTxtVerify" autocomplete="off">
        </div>
        元/天
      </div>
      <br>
      <div class="demoTable">
        全勤奖金：
        <div class="layui-inline">
          <input class="layui-input" name="full_attendance_payTxt" id="full_attendance_payTxt" lay-verify="full_attendance_payTxtVerify" autocomplete="off">
        </div>
        元/月
      </div>
      <br>
      <div class="demoTable">
        餐饮补贴：
        <div class="layui-inline">
          <input class="layui-input" name="food_payTxt" id="food_payTxt" lay-verify="food_ payTxtVerify" autocomplete="off">
        </div>
        元/月
      </div>
      <br>
      <div class="demoTable">
        交通补贴：
        <div class="layui-inline">
          <input class="layui-input" name="traffic_payTxt" id="traffic_payTxt" lay-verify="traffic_payTxtVerify" autocomplete="off">
        </div>
        元/月
      </div>
      <br>
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
        </div>
      </div>
      <!--<xblock>
        <button class="layui-btn" onclick="x_admin_show('添加','toPage.do?url=admin/workingYearsBonusAdd.html',600,400)"><i class="layui-icon"></i>添加</button>
      </xblock>-->


      <!--<div style="text-align: center">
        <table class="layui-table" lay-data="{height: 'full-200', cellMinWidth:80, url:'findWorkingYearBonusList.do', page:true, id:'idTest'}" lay-filter="demo">
          <thead>
          <tr>
            <th lay-data="{field:'wybYear', width:200, fixed: true,align: 'center'}">工龄</th>
            <th lay-data="{field:'wybBonus', minWidth:100,align: 'center'}">补贴</th>
            <th lay-data="{fixed: 'right', width:200, align:'center', toolbar: '#barDemo'}"></th>
          </tr>
          </thead>
        </table>
      </div>-->

    </div>
  </form>
</div>
<!--<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>-->
<script>
    window.onload = function () {
        //获取迟到罚金
        $.ajax({
            url:'get_late_buckle_pay.do',
            dataType:'json',
            type:'post',
            success:function(result){
                //alert(result["kvValue"]);
                $("#late_buckle_payTxt").val(result["kvValue"]);
            },
            error:function (data) {
                alert(data);
            }
        });
        //获取早退罚金
        $.ajax({
            url:'get_early_buckle_pay.do',
            dataType:'json',
            type:'post',
            success:function(result){
                //alert(result["kvValue"]);
                $("#early_buckle_payTxt").val(result["kvValue"]);
            },
            error:function (data) {
                alert(data);
            }
        });
        //获取出差补贴
        $.ajax({
            url:'get_missionallowance.do',
            dataType:'json',
            type:'post',
            success:function(result){
                //alert(result["kvValue"]);
                $("#missionallowanceTxt").val(result["kvValue"]);
            },
            error:function (data) {
                alert(data);
            }
        });
        //获取全勤奖金
        $.ajax({
            url:'get_full_attendance_pay.do',
            dataType:'json',
            type:'post',
            success:function(result){
                //alert(result["kvValue"]);
                $("#full_attendance_payTxt").val(result["kvValue"]);
            },
            error:function (data) {
                alert(data);
            }
        });
        //获取餐饮补贴
        $.ajax({
            url:'get_food_pay.do',
            dataType:'json',
            type:'post',
            success:function(result){
                //alert(result["kvValue"]);
                $("#food_payTxt").val(result["kvValue"]);
            },
            error:function (data) {
                alert(data);
            }
        });
        //获取交通补贴
        $.ajax({
            url:'get_traffic_pay.do',
            dataType:'json',
            type:'post',
            success:function(result){
                //alert(result["kvValue"]);
                $("#traffic_payTxt").val(result["kvValue"]);
            },
            error:function (data) {
                alert(data);
            }
        });
    }
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        //自定义验证规则
        form.verify({
            late_buckle_payTxtVerify: function(value){

                var number=new RegExp("^(0|[1-9][0-9]*|-[1-9][0-9]*)$");

                value = value.replace(" ","");
                if(value.length == 0){
                    return '迟到罚金不能为空';
                }
                if(value.length > 10){
                    return '输入金额过长';
                }
                if(!number.test(value)){
                    return '迟到罚金只能是整数';
                }
            },
            early_buckle_payTxtVerify: function(value){

                var number=new RegExp("^(0|[1-9][0-9]*|-[1-9][0-9]*)$");

                value = value.replace(" ","");
                if(value.length == 0){
                    return '早退罚金不能为空';
                }
                if(value.length > 10){
                    return '输入金额过长';
                }
                if(!number.test(value)){
                    return '早退罚金只能是整数';
                }
            },
            missionallowanceTxtVerify: function(value){

                var number=new RegExp("^[0-9]*$");

                value = value.replace(" ","");
                if(value.length == 0){
                    return '出差补贴不能为空';
                }
                if(value.length > 10){
                    return '输入金额过长';
                }
                if(!number.test(value)){
                    return '出差补贴只能是非负整数';
                }
            },
            full_attendance_payTxtVerify: function(value){

                var number=new RegExp("^[0-9]*$");

                value = value.replace(" ","");
                if(value.length == 0){
                    return '全勤奖金不能为空';
                }
                if(value.length > 10){
                    return '输入金额过长';
                }
                if(!number.test(value)){
                    return '全勤奖金只能是非负整数';
                }
            },
            food_payTxtVerify: function(value){

                var number=new RegExp("^[0-9]*$");

                value = value.replace(" ","");
                if(value.length == 0){
                    return '餐饮补贴不能为空';
                }
                if(value.length > 10){
                    return '输入金额过长';
                }
                if(!number.test(value)){
                    return '餐饮补贴只能是非负整数';
                }
            },
            traffic_payTxtVerify: function(value){

                var number=new RegExp("^[0-9]*$");

                value = value.replace(" ","");
                if(value.length == 0){
                    return '交通补贴不能为空';
                }
                if(value.length > 10){
                    return '输入金额过长';
                }
                if(!number.test(value)){
                    return '交通补贴只能是非负整数';
                }
            },


        });


        // 监听提交
        form.on('submit(demo1)', function(data){
            console.log(data);
            //发异步，把数据提交
            $.ajax({
                type: 'post',
                url: 'changeWageItem.do',
                //data:$('#loginInputForm').serialize(),
                data: {
                    'late_buckle_pay': $("#late_buckle_payTxt").val(),
                    'early_buckle_pay': $("#early_buckle_payTxt").val(),
                    'missionallowance': $("#missionallowanceTxt").val(),
                    'full_attendance_pay': $("#full_attendance_payTxt").val(),
                    'food_pay': $("#food_payTxt").val(),
                    'traffic_pay': $("#traffic_payTxt").val(),

                },
                /*dataType: 'json',*/
                success: function (data) {
                    //alert(data);
                    if(data==6){
                        layer.alert("保存成功", {icon: 6});
                    }
                    else{
                        layer.msg('保存失败!',{icon: 5,anim: 6});
                    }
                },
                error: function (err) {
                    alert("修改失败！");
                }

            });
            return false;
        });
    });

</script>

</body>

</html>